<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>B2B电商平台.店铺商品类型维护</title>
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/global.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path %>/include/css/proManage.css" />
<link rel="stylesheet"
	href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css"
	type="text/css"></link>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/include/pagination/page.css" media="all">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/include/css/mmt_trading.css" />
<link rel="stylesheet" type="text/css"
	href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijmo.css" />
<link rel="stylesheet" type="text/css"
	href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijcalendar.css" />
<%-- <link rel="stylesheet"	href="<%=path %>/include/layer/skin/default/layer.css" type="text/css"></link>
 --%>
<script type="text/javascript"
	src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script
	src="<%=path %>/include/wijmo/external/jquery-ui-1.8.23.custom.min.js"
	type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/external/globalize.min.js"
	type="text/javascript"></script>
<script
	src="<%=path %>/include/wijmo/external/cultures/globalize.cultures.js"
	type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijpopup.js"
	type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijcalendar.js"
	type="text/javascript"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
<script type="text/javascript"
	src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript"
	src="<%=path%>/include/pagination/jquery.pagination.js"></script>
<script type="text/javascript"
	src="<%=path%>/include/pagination/init.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/json2.js"></script>
<script src="<%=path%>/include/DatePicker/WdatePicker.js"
	charset="UTF-8" type="text/javascript"></script>
<link rel="stylesheet"
	href="<%=path %>/include/sweetalert/sweetalert.css" type="text/css"></link>
<script type="text/javascript"
	src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript"
	src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>

<style type="text/css">
.price a.price_rise {
	background-position: -62px -136px;
}

.price a.price_drop {
	background-position: -62px -95px;
}

.price a.price_null {
	background-position: -62px -15px;
	padding-right: 0px;
}

.expire a.expire_drops {
	background-position: -61px -95px;
}

.expire a.expire_rise {
	background-position: -61px -136px;
}

.expire a.expire_null {
	background-position: -61px -15px;
	padding-right: 0px;
}

.colnums-2-ab-b {
	width: 100%;
	height: auto;
	font-size: 12px !important;
}

.listed_tb_k th {
	color: #6c6c6c;
}

.listed_tb_k th.t1 {
	width: 44%;
	border-right: 0px solid #fff;
	padding: 0 5px;
}

.listed_tb_k th.t2 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t3 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t4 {
	width: 12%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t5 {
	width: 12%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t6 {
	width: 8%;
	border-right: 0px solid #fff;
}

.listed_tb_k th.t7 {
	width: 8%;
	border-right: 0px solid #fff;
}

.productName {
	border: 1px solid #FFF;
	width: 300px;
	height: 50px;
	display: table-cell;
	vertical-align: middle;
	text-align: center;
	background-color: #fff;
}

.listed_tb_k tbody td.t2 .pic_50 {
	border: 1px solid #FFF;
	width: 50px;
	height: 50px;
	display: table-cell;
	vertical-align: middle;
	text-align: center;
	background-color: #fff;
}

.t4 {
	border-right: 1px solid #ddd;
}

.t5 {
	border-right: 1px solid #ddd;
}

.t6 {
	border-right: 1px solid #ddd;
}

.t7 {
	border-right: 1px solid #ddd;
}

#ajaxSerieslist td {
	border: 1px solid #ddd;
}

thead th {
	border: 1px solid #ddd;
	padding: 4px;
}

.i_top input {
	height: 24px;
}

.sear {
	border: 1px solid #e0e0e0;
	background: #f5f5f5;
	margin-top: 10px;
	height: 80px;
	line-height: 40px;
	font-size: 14px;
}

.div_css {
	border-radius: 5px;
	background: #ddd;
}

#statusTab tr td div:hover {
	cursor: pointer;
}
</style>

<script type="text/javascript">
$(document).ready(function() {
	var clientH =  window.screen.height ;
	$("body").css('height', clientH);
	
	$("#reasonDlg").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 460,   //弹出框宽度
		height : 230,   //弹出框高度
		title : "原因",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'取消':function(){
				$(this).dialog("close");
			},
			'确定':function(){
				addReason();
			}
		}
	});
	
	$("#refundReasonDlg").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 460,   //弹出框宽度
		height : 230,   //弹出框高度
		title : "原因",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'确定':function(){
				$(this).dialog("close");
			}
		}
	});

	$("#is_support_trade_div").click(function(){
		if($("#is_support_trade_select").is(":hidden")){
			$("#is_support_trade_select").show();
		}else{
			$("#is_support_trade_select").hide();
		}
	});
	$("#sellerConfirmSelect").click(function(){
		if($("#sellerConfirmSelectDown").is(":hidden")){
			$("#sellerConfirmSelectDown").show();
		}else{
			$("#sellerConfirmSelectDown").hide();
		}
	});

	$("#calendar").wijcalendar({
		popupMode: true,
		culture: "zh-CN" ,
		selectedDatesChanged: function () {
			var selDate = $(this).wijcalendar("getSelectedDate");
			if (!!selDate)$("#frmStartTime").val(selDate.toLocaleDateString());
		}
	});
	$("#frmStartTime").click(function () {
		$("#calendar").wijcalendar("popup", {
			of: $("#frmStartTime"),
			offset: '0 2'
		});
	})
	
	$("#calendarEnd").wijcalendar({
		popupMode: true,
		culture: "zh-CN" ,
		selectedDatesChanged: function () {
			var selDate = $(this).wijcalendar("getSelectedDate");
			if (!!selDate)$("#frmEndTime").val(selDate.toLocaleDateString());
		}
	});
	$("#frmEndTime").click(function () {
		$("#calendarEnd").wijcalendar("popup", {
			of: $("#frmEndTime"),
			offset: '0 2'
		});
	});
	$("#queryBtn").on({
		mouseover:function(){
			$(this).css("font-size","14px");
		},
		mouseout:function(){
			$(this).css("font-size","12px");
		}
	});
	//_queryList();
	quick(2);
	
	_reHeight("rightFrame","contentDiv");
});

	

	
	function gets_value(val){
		//alert(val.innerHTML);
		$("#is_support_trade_value").html(val.innerHTML);
	}
	function gets_value_fk(val){
		//alert(val.innerHTML);
		$("#sellerConfirmSelectValue").html(val.innerHTML);
	}

	function more(){
		if($("#more_term").is(":hidden")){
			$("#more_term").show();
		}else{
			$("#more_term").hide();
		}
	}

	
	
	function _order3(){
		var className = $("#curtm").attr('class');
		if(className == "undefined"||className == null||className == ""){
			$("#curtm").removeClass().addClass("sel_current"); 
			$("#befm").removeClass(); 
		}
		$("#order3").val("q3");
		 $("#tsitem").val(""); 
	      /*  $("#frmCompanyName").val("买家名称"); 
	       $("#frmOrderId").val("订单号"); 
	       $("#frmBcName").val("产品名称");  */
	       $("#frmStartTime").val(""); 
	       $("#frmEndTime").val(""); 
		 //_queryList();
	       quick(2);
	}

	function _order(){
		var className = $("#befm").attr('class');
		if(className == "undefined"||className == null||className == ""){
			$("#befm").removeClass().addClass("sel_current"); 
			$("#curtm").removeClass(); 
		}
		$("#order3").val("h3");
		 $("#tsitem").val(""); 
	      /*  $("#frmCompanyName").val("买家名称"); 
	       $("#frmOrderId").val("订单号"); 
	       $("#frmBcName").val("产品名称");  */
	       $("#frmStartTime").val(""); 
	       $("#frmEndTime").val(""); 
		 //_queryList();
	       quick(0);
	}
	
	
	

	//处理查询条件的默认值
    //参数：id;ovalue原值;nvalue 新值; type：事件类型（1表示获取焦点 2表示失去焦点）
    function clearDefaultVal(id,type,ovalue,nvalue){
        if(type==1){//判断事件类型(获取焦点,情况现有默认值)
            jQuery("#"+id).val("");
        }else{
            //失去焦点，值为空，赋默认值
            if(nvalue==""){
                jQuery("#"+id).val(ovalue);
            }
        }
    }

	function _selectChange(obj){
		var state = $("#tsitem").val();
		_orderStatusOpe(state);
		_queryList();
		
	}
    function quick(state){
       $("#tsitem").val(state); 
       _orderStatusOpe(state);
//       $("#frmCompanyName").val("买家名称"); 
//       $("#frmOrderId").val("订单号"); 
//       $("#frmBcName").val("产品名称"); 
//       $("#frmStartTime").val(""); 
//       $("#frmEndTime").val(""); 
	   $("[id^='div']").removeClass("div_css");
	   $("#div"+state).addClass("div_css");
       _queryList();
    }
  
  	function _orderStatusOpe(state){
  	   $("#orderStatus").val(state); 
       
       var opeBtnShow = false;
       var exportBtnShow = true;
       var checkboxShow = true;
       var exportFinishBtnShow =false;
       
       if(state=="1"){
       } else if(state=="2"){
       	 opeBtnShow = true;
       	 $("#operateBtn").html("批量处理");
       } else if(state=="3"){
         opeBtnShow = true;
         $("#operateBtn").html("批量发货");
       } else if(state=="4"){
       } else if(state=="5"){
    	   exportFinishBtnShow = true;
       } else if(state=="6"){
       }
       if(opeBtnShow){
       	 $("#operateBtn").show();
       	 $("#grabOrderBtn").show();
       } else {
       	 $("#grabOrderBtn").hide();
       	 $("#operateBtn").hide();
       }
       if(exportBtnShow){
       	 $(".exportBtn").show();
       } else {
       	 $(".exportBtn").hide();
       }
       if(checkboxShow){
       	 $("#checkAll").show();
       } else {
       	 $("#checkAll").hide();
       }
       if (exportFinishBtnShow) {
    	   $(".exportFinishBtn").show();
       } else {
    	   $(".exportFinishBtn").hide();
       }
  	}
  
    var pagination;
	function _queryList(){
		var maijia = $("#frmCompanyName").val();
		if(maijia =="买家名称"){
			maijia = "";
		}
		var dingdanhao = $("#frmOrderId").val();
		if(dingdanhao =="订单号"){
			dingdanhao = "";
		}
		var chanping = $("#frmBcName").val();
		if(chanping =="商品名称"){
			chanping = "";
		}
		var fanwei =  $("#order3").val();
		var stime = $("#frmStartTime").val();
		var etime = $("#frmEndTime").val();
		if(stime>etime){
			parent.swal("开始时间不大于结束时间");
			return;
		}
		var state = $("#tsitem").val();
		
  		var url = "<%=path %>/orderList/getOrderList.do?fanwei="+fanwei+"&maijia="+maijia+"&dingdanhao="+dingdanhao+"&chanping="+chanping+"&state="+state+"&stime="+stime+"&etime="+etime;
  		pagination = _initPagination({'pageId':'pagination', 'cKey':'toOrderList','url': url, 'rows': 10, 'callback':_initDataList});
  		
	}
	function _initDataList(data) {
		var jStr = JSON.stringify(data);
		var rjs = jStr.replace(/"/g,"#@");
 		var d = data.rows;
 		var total = data.total;
 		var state = $("#tsitem").val();
 		var checkboxStr = "";
		var str = "";
		$("#ajaxSerieslist").empty();
		if(d.length>0){
			for(var i=0;i<d.length;i++){
					if(state!=''){
			 			checkboxStr = "<input type='checkbox' name='listbox' value='"+d[i].ORDER_UUID+"' />";
			 		}
					str +="<tr>";
					str +="	<td colspan='9' style='height: 30px;background-color: #FAFAFA;text-align:left;vertical-align: middle'>&nbsp;"+checkboxStr+"订单号：";
					str +="		<a href=\"javaScript:void('')\" onclick=\"_showDetail('"+d[i].ORDER_NO+"')\">" + d[i].ORDER_NO + "</a>";
					str +=" 	&nbsp;&nbsp;成交时间："+ d[i].CREATE_TIME;
					str +="	</td>";
					str +="</tr>";
					var num = d[i].products.length;//单个订单商品个数
					if(d[i].products.length>0){
						for(var j = 0;j<num;j++){
							str +="<tr>";
							str +="		<td  style='text-align:center;vertical-align: middle;'>";
							str +="			<div  style='width:100%;overflow:hidden;'>";
							str +="			<div  style='float:left;padding: 6px;max-width:30%;'>";
							if(d[i].products[j].PRODUCT_PIC==undefined){
								str += "        		<img src='<%=path%>/download/error/nopicture.jpg' width='50' height='43.5' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
							} else {
								str +=" 				<img src='"+d[i].products[j].PRODUCT_PIC+"' width='50' height='50' alt='' resizeimg='true' onmousedown='' onerror='javascript:this.src=\"<%=path%>/download/error/nopicture.jpg\";' style='width: 50px; height: 43.5px;'>";
							}
							str +=" 		</div>";
							str +=" 		<div  style='text-align: left;float:left;vertical-align: middle;width:70%;'>";
							str +=" 			<p style='padding: 2px;'><b>"+ d[i].products[j].PRODUCT_NAME +"</b><br/>";
							str +=" 			"+ d[i].MAIL_TYPE_NAME + "&nbsp;" + d[i].products[j].ITEM_TYPE_NAME + ":" + d[i].products[j].ITEM_CODES_NAME +"</p>";
							str +=" 		</div>";
							str +=" 		</div>";
							str +=" 	</td>";
							str +=" 	<td style='text-align:center;vertical-align: middle' >"+ d[i].products[j].PRODUCT_PRICE +"</td>";
							str +="		<td style='text-align:center;vertical-align: middle' >"+ d[i].products[j].SELL_AMOUNT;
							str +="			<br/><span style='color: #6c6c6c;font-family: verdana;'>(共"+ d[i].products[j].SELL_AMOUNT_BOOK +"本)</span>";
							str +=" 	</td>";
							/*
							str +="		<td style='text-align:center;vertical-align: middle' >";
							if(d[i].products[j].APPLY_STATUS=="0"){
								str +="<a href=\"javaScript:void('')\" onclick=\"_refundOp('" + d[i].products[j].ORDER_DETAIL_UUID + "','"+d[i].ORDER_NO+"')\">退款</a>";
							} else if(d[i].products[j].APPLY_STATUS=="1"){
								if(d[i].products[j].PAY_STATUS=="1"){
									str +="<a href=\"javaScript:void('')\" >退款成功</a> &nbsp;";
								} else {
									str +="<a href=\"javaScript:void('')\" onclick=\"_refundOp('" + d[i].products[j].ORDER_DETAIL_UUID + "','"+d[i].ORDER_NO+"')\">退款</a>";
								}
							} if(d[i].products[j].APPLY_STATUS=="2"){
								str +="<a href=\"javaScript:void('')\" onclick=\"_refundOp('" + d[i].products[j].ORDER_DETAIL_UUID + "','"+d[i].ORDER_NO+"')\">退款</a>";
							}
							str +="		</td>";
							*/
							if(num>0&&j==0){
								str +="		<td style='text-align:center;vertical-align: top;line-height:55px' rowspan='"+num+"'>"+ d[i].USER_NAME +"</td>";
								str +="		<td style='text-align:center;vertical-align: top;padding-top: 15px;padding-bottom:5px;' rowspan='"+num+"'>";
								str += 	d[i].ORDER_STATUS_NODE ;
								str +="			<br/><a href=\"javaScript:void('')\" onclick=\"_showDetail('"+d[i].ORDER_NO+"')\">详情</a>";
								str += "	</td>";
											
								var realPrice = parseFloat(d[i].SUM_REAL_MONEY);//+parseFloat(d[i].DELIVER_MONEY);
								
								str +="		<td style='text-align:center;vertical-align: top;padding-top: 15px;padding-bottom:5px;' rowspan='"+num+"'><b>"+ realPrice +"</b>";
								str +="			<br/><span style='color: #6c6c6c;font-family: verdana;'>(含快递:￥"+d[i].DELIVER_MONEY+")</span>";
								var YH_MONEY = parseFloat(d[i].YH_MONEY);
								if(YH_MONEY>0){
									str +="		<br/><span style='color: #6c6c6c;font-family: verdana;'>(已涨价:￥"+d[i].YH_MONEY+")</span>";
								} else if(YH_MONEY<0){
									YH_MONEY = 0 - YH_MONEY;
									str +="		<br/><span style='color: #6c6c6c;font-family: verdana;'>(已优惠:￥"+YH_MONEY+")</span>";
								} else {
									if(d[i].ORDER_STATUS=="1"){
										str +="<br/><a href=\"javaScript:void('')\"  onclick=\"_editPrice('" + rjs + "','"+d[i].ORDER_NO+"')\">价格修改</a>";
									}
								}
								str +="		</td>";
								str +="		<td style='text-align:center;vertical-align: top;line-height:55px' rowspan='"+num+"'>";
								if(d[i].ORDER_STATUS>=2){
								str +="			<a href='javascript:void(0)' onclick=\"_expressBill('"+d[i].ORDER_NO+"')\">邮寄</a>";
								}
								str +="		</td>";
								str +="		<td style='text-align:center;vertical-align: top;line-height:55px' rowspan='"+num+"'>";
								if(d[i].ORDER_STATUS=="2"){
									//  str +="<a href=\"javaScript:void('')\" onclick=\"_grabOrder('"+d[i].ORDER_NO+"')\">抢单</a>";
									str +="<a href=\"javaScript:void('')\" onclick=\"_agreeOrder('"+d[i].ORDER_NO+"')\">订单处理</a>";
									//	str +="&nbsp;<a href=\"javaScript:void('')\" onclick=\"_RefusedOrder('"+d[i].ORDER_NO+"')\">拒单</a>";
								} else if(d[i].ORDER_STATUS=="3"){
									str +="<a href=\"javaScript:void('')\" onclick=\"_shipOrder('"+d[i].ORDER_UUID+"','"+d[i].ORDER_NO+"',this)\">订单发货</a>";
								} else if(d[i].ORDER_STATUS=="4"){//配送中
									if(d[i].SHEETNO!="")
										str +="<a href=\"javaScript:void('')\" onclick=\"_orderSheet('"+d[i].ORDER_NO+"')\">电子面单</a>";
									//  str +="<a href=\"javaScript:void('')\" onclick=\"_reslogisticInfo('"+d[i].ORDER_NO+"',this)\">物流信息录入</a>";
								}  else if(d[i].ORDER_STATUS=="5"){
									if(d[i].SHEETNO!="")
										str +="<a href=\"javaScript:void('')\" onclick=\"_orderSheet('"+d[i].ORDER_NO+"')\">电子面单</a>";
								}  else if(d[i].ORDER_STATUS=="6"){
									//	str +="<a href=\"javaScript:void('')\" onclick=\"_evalOrder('"+d[i].ORDER_NO+"')\">评价回复</a>";
								} 
								str +="</td>";
							}
							str +="</tr>";
					  }
					
					}
					var yhxx = d[i].YHXX;//==""?"无优惠记录":d[i].YHXX.replace(/;/g,";<br/><span style='color:#FAFAFA'>&nbsp;优惠信息：</span>");
					if(yhxx!=null&&yhxx!=""){
						var yhStr = "";
						if(yhxx.indexOf(";")>0){
							var yhArr = yhxx.split(";");
							for(var ii=0;ii<yhArr.length;ii++){
								yhStr += "&nbsp;"+(ii+1)+"、"+yhArr[ii];
								if(ii<yhArr.length-1) yhStr += "<br/>";
							}
						}else{
							yhStr += "&nbsp;1、"+yhxx;
						}
						str +="<tr>";
						str +="	<td colspan='9' style='height: 30px;background-color: #FFF;text-align:left;vertical-align: middle;line-height:20px'>"+yhStr;
						str +="	</td>";
						str +="</tr>";
					}
					
			}	
		}else {
			str = "<tr><td style='height: 30px;line-height:30px;background-color: #FAFAFA;' align='center' colspan='8'>没有满足条件的记录</td></tr>";
		}
		$("#ajaxSerieslist").append(str);
		_reHeight("rightFrame", "contentDiv");
		//_reHeight();
	 }
	 function setBill(){
		 
	 }
	 //全选
	 function _checkAll(obj){
 		$("input[name='listbox']").attr("checked", obj.checked);
	 }
	 function _grabOrder(orderNo){
	 	
	 	parent.swal({
			title: "抢单", 
			text: "确认抢单吗？", 
			type: "warning",
			showCancelButton: true,
			closeOnConfirm: false,
			cancelButtonText: "取消",
			confirmButtonText: "确认",
			confirmButtonColor: "#ec6c62"
			}, function() {
				parent.swal.close();
			});
	 }
	 //批量操作
	 function _operateBatch(){
	 	var orderStatus = $("#orderStatus").val();
	 	var result = new Array();
	 	$("input[name='listbox']").each(function(){
	 		if ($(this).is(":checked")) {
                result.push($(this).attr("value"));
            }
	 	})
	 	var infoStr = "";
	 	if(orderStatus=='2'){
	 		infoStr = "请选择待处理的订单";
	 	} else if(orderStatus=='3'){
	 		infoStr = "请选择待发货的订单";
	 	} 
	 	if(result.length==0){
	 		parent.swal("", infoStr, "info");
	 		return;
	 	}
	 	var orderUuids = result.join(",");
	 	if(orderStatus=='2'){
	 		//订单处理
	 		$.ajax({
		 		type:"GET",
				url:"<%=path%>/orderList/operateBatch.do",
				data: {
					orderStatus : orderStatus,
					orderUuids : orderUuids
				},
				dataType:"json",
				async : false, //同步执行
				success:function(data){
					if(data.success){
						parent.swal("订单处理成功！","", "success");
						_queryList();
					} else {
						parent.swal("OMG", "订单处理失败!", "error");
					}
				}
			})
	 	} else 	if(orderStatus=='3'){
	 		//发货
	 		 _shipOrderBatch(orderStatus,orderUuids);
	 	} 
	 }
	 //导出
	 function _export(){
	 	var orderStatus = $("#orderStatus").val();
	 	var stime = $("#frmStartTime").val();
		var etime = $("#frmEndTime").val();
		if(stime>etime){
			parent.swal("开始时间不大于结束时间");
			return;
		}
		var url = "<%=path%>/orderList/exportOrder.do?orderStatus="+orderStatus+"&stime="+stime+"&etime="+etime;
		window.open(url);
	 }
	/**
	*订单处理
	*/
	function _agreeOrder(orderNo){
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/orderList/agreeOrder.do",
			data: {
				orderNo:orderNo
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				if(data.success){
					parent.swal("订单处理成功！","", "success");
					_queryList();
				} else {
					parent.swal("OMG", "订单处理失败!", "error");
				}
			},error:function(data){
			}
	 	});
	}
	
	/**
	*拒单
	*/
	function _RefusedOrder(orderNo){
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/orderList/RefusedOrder.do",
			data: {
				orderNo:orderNo
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				if(data.success){
					parent.swal("据单成功！", "", "success");
					_queryList();
				} else {
					parent.swal("OMG", "据单失败!", "error");
				}
			},error:function(data){
			}
	 	});
	}
	//批量发货
	function _shipOrderBatch(orderStatus,orderUuids){
		var DclientH =  window.screen.height ;
	 	var DclientW =  window.screen.width ;
		var offheight = 0;
		var offwidth = 0;
		offheight = (DclientH-290)/2;
		offwidth = (DclientW-460)/2;
		
		var url = "<%=path%>/orderList/toShipOrderPage.do?flag=batch&orderStatus="+orderStatus+"&orderUuids="+orderUuids;
		parent.layer.open({
  			title: "订单发货",
  			type: 2, 
  			fixed: true,
  			area: ['480px', '290px'],
  			offset : [offheight , offwidth],
  			content: [url,'no'], 
  			fixed: false, //不固定
			end: function(index, layero){ 
  				_queryList();
  				return false; 
			}    
		});
	}
	//发货
	function _shipOrder(orderUuid,orderNo,obj){
		var DclientH =  window.screen.height ;
	 	var DclientW =  window.screen.width ;
		var offheight = 0;
		var offwidth = 0;
		offheight = (DclientH-290)/2;
		offwidth = (DclientW-460)/2;
		
		var url = "<%=path%>/orderList/toShipOrderPage.do?orderUuid="+orderUuid+"&orderNo="+orderNo;
		parent.layer.open({
  			title: "订单发货",
  			type: 2, 
  			fixed: true,
  			area: ['500px', '310px'],
  			offset : [offheight , offwidth],
  			content: [url,'no'], 
  			fixed: false, //不固定
			end: function(index, layero){ 
  				_queryList();
  				return false; 
			}    
		});
	}
	
	
	/**
	 *发票邮寄
	 */
	 function _expressBill(orderNo){
	 	var DclientH =  window.screen.height ;
	 	var DclientW =  window.screen.width ;
		var offheight = 0;
		var offwidth = 0;
		offheight = (DclientH-350)/2;
		offwidth = (DclientW-600)/2;
	 	var url = "<%=path%>/orderList/toExpressBillPage.do?orderNo="+orderNo;
	 	parent.layer.open({
  			title: "发票邮寄",
  			type: 2, 
  			fixed: true,
  			area: ['600px', '350px'],
  			offset : [offheight , offwidth],
  			content: [url,'no'], 
			end: function(index, layero){ 
  				_queryList();
  				return false; 
			}    
		});
	 }
	/**
	 *物流信息录入
	 */
	 function _reslogisticInfo(orderNo,obj){
	 	var DclientH =  window.screen.height ;
	 	var DclientW =  window.screen.width ;
		var offheight = 0;
		var offwidth = 0;
		offheight = (DclientH-350)/2;
		offwidth = (DclientW-600)/2;
	 	var url = "<%=path%>/logistic/toInputLogisticInfoPage.do?orderNo="+orderNo;
	 	parent.layer.open({
  			title: "物流信息录入",
  			type: 2, 
  			fixed: true,
  			area: ['600px', '350px'],
  			offset : [offheight , offwidth],
  			content: [url,'no'], 
			end: function(index, layero){ 
  				_queryList();
  				return false; 
			}    
		});
	 }
	/**
	*评价
	*/
	function _evalOrder(orderNo){
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/orderList/evalOrder.do",
			data : {
				orderNo : orderNo
			},
			dataType : "json",
			async : false, //同步执行
			success : function(data) {
				if (data.success) {
					parent.swal("评价回复成功！", "", "success");
					_queryList();
				} else {
					parent.swal("OMG", "评价回复失败!", "error");
				}
			},
			error : function(data) {
			}
		});
	}
	
	function _showRefundReason(refundReason, orderNo){
		$("#refundReason").html(refundReason);
		$("#refundReasonDlg").dialog("option","title", "消费者申请退款原因").dialog("open");
	}
	
	/**
	*同意退款
	*/
	function _agreeRefund(orderDetailUuid, orderNo){
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/orderList/agreeRefund.do",
			data: {
				orderNo:orderNo,
				orderDetailUuid : orderDetailUuid
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				if(data.success){
					parent.swal("退款成功！", "", "success");
					_queryList();
				} else {
					parent.swal("OMG", data.msg, "error");
				}
			},error:function(data){
			}
	 	});
	}
	/**
	*拒绝退款
	*/
	function _rejectRefund(orderDetailUuid, orderNo){
		$("#reason").val("");
		$("#orderDetailUuid").val(orderDetailUuid);
		$("#orderNo").val(orderNo);
		$("#reasonDlg").dialog("option","title", "拒绝退款").dialog("open");
	}
	
	//保存审核不通过原因或者停用原因
	function addReason(){
		var reason = $("#reason").val();
		var checkFlag = _checkFlag(reason);
		if(checkFlag){
			$.ajax({
				cache: true,
				type: "POST",
				url: "<%=path%>/orderList/rejectRefund.do",
				async: false,
				data:$('#reasonFm').serialize(),
				error: function(request) {
					alert('服务器拒绝访问!');  
				},
				success: function(data) {
					data = eval('(' + data + ')');
					if(data.success){
						parent.swal("拒绝退款成功！", "", "success");
						_queryList();
						$("#reasonDlg").dialog("close");
					}else {
						parent.swal("OMG", "拒绝退款失败！", "error");
					}
				}
			});
		}
	}
	
	//验证是否填写审核不通过原因或者停用原因
	function _checkFlag(reason){
	 	if(reason == '' || reason == 'undefined'){
			$("#firstTip").show();
			return false;
		}else{
			$("#firstTip").hide();
		}
		return true;
	 }
	
	//验证是否填写拒绝退款原因
	function _checkReason(reason){
	 	if(reason == '' || reason == 'undefined'){
			layer.alert('请输入原因');
			return false;
		}
		return true;
	 }
	
	//退款操作
	function _refundOp(orderDetailUuid, orderNo){
		var url = "<%=path%>/orderList/refundOp.do?orderNo="+orderNo+"&orderDetailUuid="+orderDetailUuid;
		parent.layer.open({
 			title:'退款操作',
			type: 2,
			fixed: false, //不固定
			offset: '100px',
			area: ['400px', '250px'],
			shadeClose: false, //点击遮罩关闭
			content: url,
			btn: ['确定', '关闭'],
			yes: function(index, layero){
				//按钮【按钮一】的回调
				var body = parent.layer.getChildFrame('body', index);
				var iframeWin = parent[layero.find('iframe')[0]['name']];   //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
				iframeWin.setValues();
				console.log("iframeWin:" + iframeWin + ",$('#refundType').val()=" + parent.$('#refundType').val() + ",$('#rejectReason').val()=" + parent.$('#rejectReason').val());
				//执行退款操作
				var flag = iframeWin._checkReason();
				if(flag){
					var refundType = parent.$("#refundType").val();
					var refundOrderNo = parent.$("#refundOrderNo").val();
					var refundOrderDetailUuid = parent.$("#refundOrderDetailUuid").val();
					var rejectReason = parent.$("#rejectReason").val();
					
					if(refundType == '1'){
						_agreeRefund(refundOrderDetailUuid, refundOrderNo);
					}else if(refundType == '2'){
						_refuseRefund(refundOrderDetailUuid, refundOrderNo, rejectReason);
					}
				}
				
			},
			btn2: function(index, layero){
				//按钮【按钮二】的回调
				//return false 开启该代码可禁止点击该按钮关闭
			},
			maxmin:true
		});
	}
	
	function _refuseRefund(orderDetailUuid, orderNo, rejectReason){
		var checkFlag = _checkReason(rejectReason);
		if(checkFlag){
			$.ajax({
				cache: true,
				type: "POST",
				url: "<%=path%>/orderList/rejectRefund.do",
				async: false,
				data: {
					orderNo:orderNo,
					orderDetailUuid : orderDetailUuid,
					reason : rejectReason
				},
				error: function(request) {
					alert('服务器拒绝访问!');  
				},
				success: function(data) {
					data = eval('(' + data + ')');
					if(data.success){
						parent.swal("拒绝退款成功！", "", "success");
						_queryList();
						$("#reasonDlg").dialog("close");
					}else {
						parent.swal("OMG", "拒绝退款失败！", "error");
					}
				}
			});
		}
	}
	
	//改价
	function _editPrice(jStr, orderNo){
		var url = "<%=path%>/orderList/editPrice.do?orderNo="+orderNo;
		parent.layer.open({
 			title:'修改订单价格',
			type: 2,
			area: ['800px', '450px'],
			offset: '100px',
			shadeClose: false, //点击遮罩关闭
			content: url,
			btn: ['确定', '关闭'],
			yes: function(index, layero){
				//按钮【按钮一】的回调
				var body = parent.layer.getChildFrame('body', index);
				var iframeWin = parent[layero.find('iframe')[0]['name']];   //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
				iframeWin.setValues();
				console.log("iframeWin:" + iframeWin + ",$('#finalDiscountMoney').val()=" + parent.$('#finalDiscountMoney').val() + ",$('#finalDeliverMoney').val()=" + parent.$('#finalDeliverMoney').val());
				updatePrice();
				parent.layer.closeAll();
			},
			btn2: function(index, layero){
				//按钮【按钮二】的回调
				//return false 开启该代码可禁止点击该按钮关闭
			},
			maxmin:true
		});
	}
	
	function updatePrice(){
		var finalDiscountMoney = parent.$('#finalDiscountMoney').val();
		var finalDeliverMoney = parent.$('#finalDeliverMoney').val();
		var sum_real_money = parent.$('#sum_real_money').val();
		if(finalDiscountMoney == '' || finalDiscountMoney == 'undefined' ||
			finalDeliverMoney == '' || finalDeliverMoney == 'undefined'){
			return false;
		}else {
			$.ajax({
				cache: true,
				type: "POST",
				url: "<%=path%>/orderList/updatePrice.do",
				async: false,
				data:{
					orderNo : parent.$("#finalDiscountOrderNo").val(),
					discountMoney : finalDiscountMoney,
					sum_real_money : sum_real_money,
					deliverMoney : finalDeliverMoney
				},
				error: function(request) {
					alert('服务器拒绝访问!');  
				},
				success: function(data) {
					data = eval('(' + data + ')');
					if(data.success){
						parent.swal("订单改价成功！", "", "success");
						_queryList();
					}else {
						parent.swal("OMG", "订单改价失败！", "error");
					}
				}
			});
		}
	}
	
	function _showDetail(orderNo){
		var url = "<%=path%>/orderList/showDetail.do?orderNo="+orderNo;
		location.href = url;
	}

	function _orderSheet(orderNo){
		$.ajax({
			type:"post",
			url:"<%=path%>/orderList/getOrderSheet.do",
			dataType:"text",
			data:{orderNo:orderNo},
			success:function(data){
				if(data){
					parent.layer.open({
					  	type: 1,
					  	skin: 'layui-layer-rim layer_sheet_center', //加上边框
					  	area: ['520px', '100%'], //宽高
					  	offset: '0px',
					  	btn: ['关闭'],
					  	content: data
					});
				}
			}
		});
	}
	//打印
	 function _printInfo(){
	 	var orderStatus = $("#orderStatus").val();
	 	var stime = $("#frmStartTime").val();
		var etime = $("#frmEndTime").val();
		if(stime>etime){
			parent.swal("开始时间不大于结束时间");
			return;
		}
		var url = "<%=path%>/orderList/toOrderPrintListPage.do?orderStatus="+orderStatus+"&stime="+stime+"&etime="+etime;
		window.open(url);
	 }
	 //进入统计导出所有数据
	 function exportFinishOrder() {
		 var stime = $("#frmStartTime").val();
		 var etime = $("#frmEndTime").val();
		 window.location.href ="<%=path%>/orderList/exportOrderFinish.do?&stime="
				+ stime + "&etime=" + etime;
	}
</script>
</head>

<body style="font-family: '微软雅黑'">
	<input type="hidden" id="finalDiscount" name="finalDiscount">
	<input type="hidden" id="finalDiscountMoney" name="finalDiscountMoney">
	<input type="hidden" id="sum_real_money" name="sum_real_money" />
	<input type="hidden" id="finalDeliverMoney" name="finalDeliverMoney">
	<input type="hidden" id="finalDiscountOrderNo"
		name="finalDiscountOrderNo">
	<div id="contentDiv" style="padding: 5px; width: 99%;">
		<div class="colnums-2-ab-b">
			<div class="toptil">
				已卖出商品
				<div style="float: right; margin: 5px 40px 0px 0px;"></div>
			</div>
			<input name="order3" id="order3" type="hidden" value="" />
			<div class="tag_x" style="padding: 0px; width: 99.5%;">
				<a id="curtm" href="javascript:_order3();" class="sel_current"
					style="cursor: pointer;">近三个月内订单</a> <a id="befm"
					href="javascript:_order();" style="cursor: pointer;">三个月前订单</a>
			</div>
			<div class="sear"
				style="width: 99%; padding-left: 4px; overflow: hidden; height: auto;">
				<div
					style="width: 85.5%; border: 0px solid red; float: left; background-color: #FAFAFA; border-right: 1px dashed #E0E0E0;">
					买家名称:&nbsp; <input id="frmCompanyName" name="frmCompanyName"
						style="height: 24px; width: 120px; padding-left: 3px" />
					订单号:&nbsp; <input id="frmOrderId" name="frmOrderId"
						style="height: 24px; width: 120px; padding-left: 3px" />
					商品名称:&nbsp; <input id="frmBcName" name="frmBcName"
						style="height: 24px; width: 120px; padding-left: 3px" /> <br />
					下单时间:&nbsp; <input type="text" id="frmStartTime"
						name="frmStartTime"
						onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,maxDate:'#F{$dp.$D(\'frmEndTime\')}'})"
						style="width: 120px; height: 24px; padding-left: 3px"
						onfocus="WdatePicker({position:{left:78,top:131}})" class="Wdate"
						value="<c:out value='${frmStartTime }'/>" readonly /> <span
						style="margin: 0px 15px;">至</span> <input type="text"
						id="frmEndTime" name="frmEndTime"
						onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,minDate:'#F{$dp.$D(\'frmStartTime\')}'})"
						style="width: 120px; height: 24px; padding-left: 3px; margin-right: 2px;"
						onfocus="WdatePicker({position:{left:249,top:131}})" class="Wdate"
						value="<c:out value='${frmEndTime }'/>" readonly /> 交易状态:&nbsp; <select
						class="s_list" id="tsitem" name="tsitem"
						onchange="_selectChange(this)"
						style="width: 120px; height: 24px; font-family: '微软雅黑';">
						<option value="">全部状态</option>
						<option value="0">交易关闭</option>
						<option value="1">等待买家付款</option>
						<option value="2">买家已付款/已下单</option>
						<option value="3">已处理</option>
						<option value="4">已发货</option>
						<option value="5">完成订单</option>
						<!-- 
						<option value="6">已评价</option>
						 -->
					</select>
				</div>
				<div style="float: left; width: 14.3%; height: 80px;">
					<div style="margin: 15px 15px; border: 0px solid blue;">
						<button id="queryBtn" class="orange_search_btn3"
							onclick="_queryList()">查询</button>
						<button id="exportFinishBtn" type="button" class="orange_search_btn3 exportFinishBtn"
							style="display:none;" onclick="javascript:exportFinishOrder()">导出完成</button>
					</div>
				</div>
			</div>


			<div class="ts_tran" style="padding: 2px; width: 99%;">
				<!-- <p style="margin: 5px 0px;width:98%;">
					<strong class="ts_ttitle">交易提醒：</strong> 
					<a href="javascript:quick(0);" id="qx">交易关闭<em id="qxs"></em></a>&nbsp;
					<a href="javascript:quick(1);" id="xd">等待买家付款<em id="xds"></em></a>&nbsp;
					<a href="javascript:quick(2);" id="jd">买家已付款/已下单<em id="jds"></em></a>&nbsp;
					<a href="javascript:quick(3);" id="gd">已处理<em id="gds"></em></a>&nbsp;
					<a href="javascript:quick(4);" id="ps">已发货<em id="pss"></em></a>&nbsp;
					<a href="javascript:quick(5);" id="wc">完成订单<em id="wcs"></em></a>&nbsp;
					<a href="javascript:quick(6);" id="pj">已评价<em id="pjs"></em></a>
					<input type="hidden" id="orderStatus" value="" />
					<button id="operateBtn" class="orange_search_btn3" onclick="_operateBatch()" style="display:none;" >处理</button>
					<button id="exportBtn" class="orange_search_btn3" onclick="_export()" style="display:none;" >导出</button>
				</p> -->
				<table id="statusTab"
					style="width: 98%; text-align: center; line-height: 40px; color: #039">
					<tr>
						<td style="width: 70px;"><strong class="ts_ttitle"
							style="color: #222">交易提醒：</strong></td>
						<td style="width: 63px;"><div id="div0"
								onclick="javascript:quick(0);">交易关闭</div></td>
						<td style="width: 87px;"><div id="div1"
								onclick="javascript:quick(1);">等待买家付款</div></td>
						<td style="width: 120px;"><div id="div2"
								onclick="javascript:quick(2);">买家已付款/已下单</div></td>
						<td style="width: 55px;"><div id="div3"
								onclick="javascript:quick(3);">已处理</div></td>
						<td style="width: 55px;"><div id="div4"
								onclick="javascript:quick(4);">已发货</div></td>
						<td style="width: 63px;"><div id="div5"
								onclick="javascript:quick(5);">完成订单</div></td>
						<!-- 
						<td style="width: 55px;" ><div id="div6" onclick="javascript:quick(6);">已评价</div></td>
						 -->
						<td style="text-align: left;">&nbsp; <input type="hidden"
							id="orderStatus" value="" /> <!-- 
							<button id="grabOrderBtn" class="orange_search_btn3 " onclick="_grabOrder('');" style="display:none;" >抢单</button>
							 --> <!-- 
							<button id="operateBtn" class="orange_search_btn3" onclick="_operateBatch()" style="display:none;" >处理</button>
							
							<button id="exportBtn" class="orange_search_btn3 exportBtn" onclick="_export();" style="display:none;" >导出</button>
							<button id="printBtn" class="orange_search_btn3 exportBtn" onclick="_printInfo();" style="display:none;" >打印</button>
							 -->
						</td>
					</tr>
				</table>
			</div>

			<div class="listed_tb_k"
				style="margin-top: 0px; width: 99.5%; border: none;">
				<table cellspacing="0" cellpadding="0" width="100%">
					<thead>
						<tr>
							<th
								style="text-align: center; vertical-align: middle; width: 34%;"><input
								type="checkbox" id="checkAll" onclick="_checkAll(this)"
								style="display: none;" />宝贝</th>
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">单价</th>
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">数量(份数)</th>
							<!-- 
							<th style="text-align:center;vertical-align: middle;width:6%;">售后</th>
							 -->
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">买家</th>
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">交易状态</th>
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">订单金额</th>
							<th
								style="text-align: center; vertical-align: middle; width: 6%;">发票</th>
							<!-- 
	                <th style="text-align:center;vertical-align: middle;width:10%;" >评价状态</th>
	                 -->
							<th
								style="text-align: center; vertical-align: middle; width: 10%;">操作</th>
						</tr>
					</thead>
					<tbody id="ajaxSerieslist">
					</tbody>
				</table>
			</div>
			<div class="clear"></div>
			<div class="sort_page">
				<div class="bottom_page">
					<div id="pagination"></div>
				</div>
			</div>
			<!-- InstanceEndEditable -->
		</div>
		<!--colnums-2-ab-b begin-->
		<div class="clear"></div>
	</div>

	<!-- 消费者申请退款查询 -->
	<div id="refundReasonDlg"
		style="display: none; overflow: hidden; padding-top: 56px;">
		<form id="refundReasonFm" name="refundReasonFm" method="post"
			action="" novalidate="novalidate" enctype="multipart/form-data">
			<div class="content_block">
				<div class="xp_creat">
					<p class="creat_name">
						<label>原因： <span id="refundReason"> </span>
						</label>
					</p>
				</div>
			</div>
		</form>
	</div>
	<!-- 填写 拒绝退款原因 -->
	<div id="reasonDlg"
		style="display: none; overflow: hidden; padding-top: 56px;">
		<form id="reasonFm" name="reasonFm" method="post" action=""
			novalidate="novalidate" enctype="multipart/form-data">
			<div class="content_block">
				<div class="xp_creat">
					<p class="creat_name">
						<label>原因： <input type="text" name="reason" id="reason"
							maxlength="20"> <input type="hidden" name="orderNo"
							id="orderNo" /> <input type="hidden" name="orderDetailUuid"
							id="orderDetailUuid" />
						</label>
					</p>
					<div class='tips-errow' id="firstTip"
						style="display: none; color: red; font-size: 14px;">请输入原因</div>
				</div>
			</div>
		</form>
	</div>

</body>
</html>
